<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>定时跳转</title>
</head>

<body onload="redirect()">
    <p id="countdown">10秒之后页面跳转</p>
    <input type="button" value="开始" id="start" onclick="redirect()">
    <input type="button" value="暂停" id="pause" onclick="zanting()">
</body>

</html>
<script>
    // 定时跳转脚本
    var timer;
    var countdown = 10; // 初始倒计时时间（秒）
    function redirect() {
        if (!timer) {
           timer = setInterval(function(){
            if (countdown > 0) {
                // 每秒更新倒计时
                document.getElementById("countdown").textContent = `${countdown}秒之后页面跳转`
                countdown--;

            }else{
                // 清除定时器并跳转页面
                clearInterval(timer);
                window.location.href = "http://baidu.com"; 
            }
           },1000) 
        }
    }

    // 暂停按钮事件
    function zanting() {
        clearInterval(timer);
        timer = null; // 重置定时器变量
    }
</script>